﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HtmlAgilityPack;
using Kooboo.HtmlFunc.Function;
using Kooboo.HtmlFunc.Providers;

namespace Kooboo.HtmlFunc.Analysis.Visitors
{
    public class MenuVisitor : StartEndVisitor
    {
        public MenuVisitor(VisitorContext context)
            : base(context, FuncType.Menu)
        {
        }

        protected override object OnQualified(HtmlCommentNode startNode, HtmlCommentNode endNode)
        {
            // add
            var menu = Provider.Factory.GetProvider<IMenu>();
            menu.StartNode = startNode;
            menu.EndNode = endNode;
            this.Context.Result.Menus.Add(menu);

            // ret context mark
            return menu;
        }

        protected override FuncType ExclusiveType
        {
            get
            {
                return this.FuncType
                    | FuncType.Label
                    | FuncType.HtmlBlockPart
                    | FuncType.HtmlPart;
                //| FuncType.ViewPart
                //| FuncType.List
                //| FuncType.Detail;
            }
        }
    }
}
